package com.matt.controller.web.courseV2;

import com.matt.commons.model.StatusResponse;
import com.matt.domain.courseV2.AbilityUser;
import com.matt.domain.courseV2.po.AbilityPO;
import com.matt.service.courseV2.AbilityService;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;


@RestController
@RequestMapping("/api/ability")
@Slf4j
@Api(tags = "教学 - 能力指标")
public class AbilityController {

    @Autowired
    private AbilityService abilityService;




    @ApiOperation(value = "列表")
    @PostMapping("/list")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "childrenId", value = "宝宝ID", required = true, dataType = "string"),
            @ApiImplicitParam(paramType = "query", name = "timeAxis", value = "时间轴", required = true, dataType = "string"),
            @ApiImplicitParam(paramType = "query", name = "name", value = "名称", required = false, dataType = "string"),
            @ApiImplicitParam(paramType = "query", name = "states", value = "是否完成：0否，1是", required = false, dataType = "int"),
            @ApiImplicitParam(paramType = "query", name = "completeStates", value = "完成状态：1按时完成，2提前完成，3超时完成", required = false, dataType = "int"),
    })
    @ApiResponses({
            @ApiResponse(code = 000000, message = "successful", response = AbilityPO.class),
    })
    public StatusResponse list(String childrenId,String timeAxis,String name,String states,String completeStates) {
        Map map = abilityService.list( childrenId, timeAxis,name, states, completeStates);
        return StatusResponse.success(map);
    }


    @ApiOperation(value = "添加")
    @PostMapping("/add")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "childrenId", value = "宝宝ID", required = true, dataType = "string"),
            @ApiImplicitParam(paramType = "query", name = "abilityId", value = "标签ID", required = true, dataType = "string"),
            @ApiImplicitParam(paramType = "query", name = "url", value = "附件", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 000000, message = "successful", response = AbilityPO.class),
    })
    public StatusResponse add(String childrenId, String abilityId, String url) {
        AbilityUser abilityUser = abilityService.add( childrenId, abilityId, url);
        return StatusResponse.success(abilityUser);
    }


    @ApiOperation(value = "时间轴列表")
    @PostMapping("/timeAxis_list")
    public StatusResponse timeAxis() {
        List<Map> map = abilityService.timeAxis();
        return StatusResponse.success(map);
    }

    @ApiOperation(value = "月统计")
    @PostMapping("/month_count")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "childrenId", value = "宝宝ID", required = true, dataType = "string"),
            @ApiImplicitParam(paramType = "query", name = "time", value = "时间:yyyy-mm", required = true, dataType = "string"),
    })
    public StatusResponse monthCount(String childrenId,String time) {
        List<Map> map = abilityService.monthCount(childrenId,time);
        return StatusResponse.success(map);
    }

}
